﻿using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Messaging;

namespace MG.SmartHMI.ViewModel
{
    public partial class MainViewModel : ObservableRecipient
    {
        [ObservableProperty]
        private string title = "MG.SmartHMI";

        public MainViewModel()
        {
            Register();
            // ProcessEngine.Instance.InitDevices();
        }

        private void Register()
        {
            WeakReferenceMessenger.Default.Register<string, string>(this, "MainWindCloseSignal", MainWindCloseSlot);
        }

        private void MainWindCloseSlot(object recipient, string message)
        {
            Task.Run(async () =>
            {
                //modify by mfj 20250515,解决软件关闭时，运动模块的一些关闭动作不能执行的问题。
                // SysConfig.Instance.UpdateLastSln();
                //ProcessEngine.Instance.UnInitDevices();
                await Task.Delay(500);
            });
        }
    }
}